﻿@{

}
<style type="text/css">
    #showProduct ul li.ranking {
        background-color: #00BCD4;
    }

    #showProduct ul li.otherDataShowBtn {
        margin-left: 48%;
    }
</style>

<div class="page">
    <script type="text/javascript">

        var loading = false;
        var page = 0;

        $(function () {
            productIncomeGeneral(false);
        });

        $(function () {
            $.init();

            $(document).on('infinite', '.infinite-scroll', function () {

                var maxItems = parseInt($("#maxPage").val());

                // 如果正在加载，则退出
                if (loading) return;

                // 设置flag
                loading = true;

                productIncomeGeneral(true);

                if (page >= maxItems) {
                    $.detachInfiniteScroll($('.infinite-scroll'));
                    $('.infinite-scroll-preloader').remove();
                    return;
                }
            });
        })

        function productIncomeGeneral(isScroll) {
            var beginTime = $("#beginTime").val();
            var endTime = $("#endTime").val();
            var productName = $("#productName").val();
            var plateformType = $("#plateformType").val();
            if (isScroll) {
                page++;
            } else {
                page = 1;
            }
            $.showPreloader('Loading...');
            $.post("/Product/_ProductList", { beginTime: beginTime, endTime: endTime, productName: productName, plateformType: plateformType, page: page }, function (result) {
                if (page == 1) {
                    $("#showProduct").html(result);
                } else {
                    $("#showProduct").append(result);
                }
                $.hidePreloader();
                loading = false;
            })
        }

        function showHide(obj) {
            var temp = $(obj).find("span");
            var otherData = $(obj).siblings(".otherData");
            if (temp.hasClass("icon-down")) {
                otherData.show();
                temp.removeClass("icon-down").addClass("icon-up");
            } else if (temp.hasClass("icon-up")) {
                otherData.hide();
                temp.removeClass("icon-up").addClass("icon-down");
            }
        }

        function GoToDetail(obj) {
            var temp = $(obj);
            var productId = temp.attr("data-productId");
            var productName = temp.text();
            var plateformType = temp.attr("data-plateformType");
            var syjno = temp.attr("data-syjno");
            var beginTime = $("#beginTime").val();
            var endTime = $("#endTime").val();

            $.showPreloader('Loading...');

            window.location.href = "/Product/Detail?productId=" + productId + "&productName=" + productName + "&plateformType=" + plateformType + "&beginTime=" + beginTime + "&endTime=" + endTime + "&syjNo=" + syjno;
        }

    </script>
    <header class="bar bar-nav">
        <a class="button button-link button-nav pull-left back" href="/Home/Index">
            <span class="icon icon-left"></span>
            返回
        </a>
        <h1 class="title">销售排行</h1>
    </header>
    <div class="content infinite-scroll" data-distance="100">
        <div class="list-block">
            <ul>
                <li>
                    <div class="item-content">
                        <div class="item-inner">
                            <div class="item-title label">开始时间</div>
                            <div class="item-input">
                                <input type="date" placeholder="开始时间" id="beginTime" value="@DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd")">
                            </div>
                        </div>
                    </div>
                </li>

                <li>
                    <div class="item-content">
                        <div class="item-inner">
                            <div class="item-title label">结束时间</div>
                            <div class="item-input">
                                <input type="date" placeholder="结束时间" id="endTime" value="@DateTime.Now.ToString("yyyy-MM-dd")">
                            </div>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="item-content">
                        <div class="item-inner">
                            <div class="item-title label">所属平台</div>
                            <div class="item-input">
                                <select id="plateformType">
                                    <option value="-1">全部</option>
                                    <option value="0">实体</option>
                                    <option value="1">电商</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </li>

                <li>
                    <div class="item-content">
                        <div class="item-inner">
                            <div class="item-title label">商品名称</div>
                            <div class="item-input">
                                <input type="text" placeholder="商品名称" id="productName" />
                            </div>
                        </div>
                    </div>
                </li>

                <li>
                    <p><a href="#" class="button button-fill button-big button-success" onclick="productIncomeGeneral(false)">查询</a></p>
                </li>
            </ul>
        </div>
        <div class="content-block-title">单品销售排行</div>
        <input type="hidden" id="maxPage" value="0" />
        <div class="list-block" id="showProduct">

        </div>
        <div class="infinite-scroll-preloader">
            <div class="preloader"></div>
        </div>
    </div>
</div>
